<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateSystemAdminsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('system_admins', function (Blueprint $table) {
            $table->id()->comment('后台管理员表');
            $table->integer('merchant_id')->nullable()->comment('商户id')->index();
            $table->string('account',32)->comment('后台管理员账号');
            $table->string('password',100)->comment('后台管理员密码');
            $table->string('avatar')->nullable()->comment('后台管理员头像');
            $table->string('real_name',16)->comment('真实姓名');
            $table->string('roles')->nullable()->comment('后台管理员权限');
            $table->string('last_ip',16)->nullable()->comment('最后一次登录ip');
            $table->timestamp('last_time')->nullable()->comment('最后一次登录时间');
            $table->tinyInteger('level')->default(0)->comment('等级 默认为0');
            $table->integer('login_count')->default(1)->comment('登录次数');
            $table->tinyInteger('status')->default(1)->comment('状态 0禁用 1正常');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('system_admins');
    }
}
